package com.botu.springclouddubbocomsumer;

import com.alibaba.cloud.nacos.ribbon.NacosRule;
import com.alibaba.csp.sentinel.adapter.dubbo.fallback.DubboFallback;
import com.alibaba.csp.sentinel.adapter.dubbo.fallback.DubboFallbackRegistry;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.apache.dubbo.rpc.AsyncRpcResult;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Result;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableDiscoveryClient
public class SpringCloudDubboComsumerApplication {

    public static void main(String[] args) {
        DubboFallbackRegistry.setConsumerFallback(new DubboFallback() {
            @Override
            public Result handle(Invoker<?> invoker, Invocation invocation, BlockException ex) {
                return AsyncRpcResult.newDefaultAsyncResult("服务器处理不过来或者挂掉了", invocation);
            }
        });
        DubboFallbackRegistry.setProviderFallback(new DubboFallback() {
            @Override
            public Result handle(Invoker<?> invoker, Invocation invocation, BlockException ex) {
                return AsyncRpcResult.newDefaultAsyncResult("服务器处理不过来或者挂掉了", invocation);
            }
        });
        SpringApplication.run(SpringCloudDubboComsumerApplication.class, args);
    }



}
